<?php
	require_once('include/managedCreditCardPaymentTest.php');
	require_once('config.php');
	$eway_soapclient = new managedCreditCardPaymentTest();
	if(isset($_POST) && $_POST['action'] == 'add'){
		//Process add customer request
		$new_customer = new CreateCustomer();
		$new_customer->Title = $_POST['title'];
		$new_customer->FirstName = $_POST['firstname'];
		$new_customer->LastName = $_POST['lastname'];
		$new_customer->Address = $_POST['addr'];
		$new_customer->Suburb = $_POST['suburb'];
		$new_customer->State = $_POST['state'];
		$new_customer->Company = $_POST['company'];
		$new_customer->PostCode = $_POST['zip'];
		$new_customer->Country = strtolower($_POST['country']);
		$new_customer->CustomerRef = $_POST['customer_ref'];
		$new_customer->Email = $_POST['email'];
		$new_customer->JobDesc = $_POST['job_desc'];
		$new_customer->Mobile = $_POST['mobile'];
		$new_customer->Phone = $_POST['phone'];
		$new_customer->URL = $_POST['url'];
		$new_customer->Comments = $_POST['comments'];
		$new_customer->Fax = $_POST['fax'];
		$new_customer->CCExpiryMonth = $_POST['ccexpirymonth'];
		$new_customer->CCExpiryYear = $_POST['ccexpiryyear'];
		$new_customer->CCNameOnCard = $_POST['ccnameoncard'];
		$new_customer->CCNumber = $_POST['ccnumber'];


		// build header for the request
		$eway_soapheader = new eWAYHeader();
		$eway_soapheader->eWAYCustomerID = $eWAYCustomerID;
		$eway_soapheader->Username = $username;
		$eway_soapheader->Password = $password;
	    //var_dump($eway_soapclient); exit;
		try{
			$new_customer_response = new CreateCustomerResponse();
			$new_customer_response = $eway_soapclient->create_customer($new_customer, $eway_soapheader);
			echo "<div align=\"center\">Add new customer successfully. Response: " . $new_customer_response->CreateCustomerResult ;

		}catch(SoapFault $e){
			$error = $e->getMessage();
			$errno = $e->getCode();
			echo "<div><b>An error occurred:</b><br><pre><i>$error</i></pre>";
		};
		echo "<br><a href=\"javascript:history.go(-1);\">Back</a></div>";

	}
?>
